package com.nowcoder.community.service;

import com.nowcoder.community.dao.alphaDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Service
public class Alphaservice {

    @Autowired
    private alphaDao alphaDao;

    public Alphaservice() {
        System.out.println("实例化Serivice");
    }

    /**
     * 这个注解表示这个方法会在构造器之后调用
     */
    @PostConstruct
    public void init() {
        System.out.println("初始化Service");
    }

    /**
     * 在对象销毁以前调用（对象销毁以后也没有办法调用了）
     */
    @PreDestroy
    public void destroy() {
        System.out.println("销毁alphaService");
    }

    public String find() {
        return alphaDao.select();
    }
}
